home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / TC Prog Guide.cpt / picture ƒ / atring.c < prev    next >
Text File  |  1990-11-09  |  2KB  |  93 lines

  1. /*
  2. *    FILE:        atring.c
  3. *    AUTHOR:        R. Gonzalez
  4. *    CREATED:    November 9, 1990
  5. *
  6. *    defines methods for atomic ring animated segment
  7. */
  8.  
  9. # include    "atring.h"
  10. # include    "trans.h"
  11. # include    "cube.h"
  12.  
  13. # define    NUM_SATELLITES        2
  14. # define    RADIUS                2.
  15. # define    SATELLITE_TYPE        Fast_Cube
  16. # define    ANIMATED_SATELLITES    FALSE
  17. # define    ANGULAR_VELOCITY    -PI/10.
  18.  
  19. /******************************************************************
  20. *    initialize
  21. ******************************************************************/
  22. boolean    Atomic_Ring::init(void)
  23. {
  24.     int                i;
  25.     Translation        *transl;
  26.     Scaling            *scale;
  27.     Rotation_Z        *roty;
  28.     Transformation    *combination1,
  29.                     *combination2;
  30. /*    The following temps are needed due to a bug in Think C when
  31.     handling arrays of pointers, when the array is an instance var.
  32. */
  33.     Segment            *temp_seg;
  34.     Transformation    *temp_trans;
  35.     
  36.     Animated_Segment::init();
  37.     
  38.     transl = new(Translation);
  39.     transl->init();
  40.     transl->set(RADIUS-.5,-.5,-.5);
  41.     scale = new(Scaling);
  42.     scale->init();
  43.     scale->set(.2,.2,.2);
  44.     roty = new(Rotation_Z);
  45.     roty->init();
  46.     combination1 = new(Transformation);
  47.     combination1->init();
  48.     combination2 = new(Transformation);
  49.     combination2->init();
  50.     
  51.     num_segments = NUM_SATELLITES;
  52.     
  53.     for (i=0 ; i<NUM_SATELLITES ; i++)
  54.     {
  55.         temp_seg = new(SATELLITE_TYPE);
  56.         segment[i] = temp_seg;
  57.         segment[i]->init();
  58.         roty->set(i*2.*PI/NUM_SATELLITES);
  59.         combination1->combine(transl,roty);
  60.         combination2->combine(combination1,scale);
  61.         segment[i]->move(combination2);
  62.         temp_trans = new(Rotation_Z);
  63.         animation[i] = temp_trans;
  64.         animation[i]->init();
  65.         ((Rotation_Z*) animation[i])->set(ANGULAR_VELOCITY);
  66.         if (ANIMATED_SATELLITES)
  67.             log_animated_segment(segment[i]);
  68.     }
  69.     
  70.     temp_seg = new(Fast_Cube);
  71.     segment[i=num_segments++] = temp_seg;
  72.     segment[i]->init();
  73.     transl->set(-.5,-.5,-.5);
  74.     segment[i]->move(transl);
  75.     temp_trans = new(Transformation);
  76.     animation[i] = temp_trans;
  77.     animation[i]->init();
  78.     
  79.     transl->destroy();
  80.     delete(transl);
  81.     scale->destroy();
  82.     delete(scale);
  83.     roty->destroy();
  84.     delete(roty);
  85.     combination1->destroy();
  86.     delete(combination1);
  87.     combination2->destroy();
  88.     delete(combination2);
  89.     
  90.     return TRUE;
  91. }
  92.  
  93.